﻿using WeifenLuo.WinFormsUI.Docking;
using System.Windows.Forms;

namespace CodeSmith
{
    public partial class BottomForm : DockContent
    {
        private MainForm mainForm = null;
        private LeftForm leftForm = null;
        public BottomForm(MainForm _mainForm, LeftForm _leftForm)
        {
            InitializeComponent();

            mainForm = _mainForm;
            mainForm.logEvent += new MainForm.logDelegate(WriteLine);
            leftForm = _leftForm;
            leftForm.logEvent += new LeftForm.logDelegate(WriteLine);
        }

        private void WriteLine(string text)
        {
            if (this.bottomRichTextBox.Lines.Length >= 200)
                this.bottomRichTextBox.Clear();
            this.bottomRichTextBox.Text += (text + "\n");
            this.bottomRichTextBox.SelectionStart = this.bottomRichTextBox.Text.Length;
            this.bottomRichTextBox.ScrollToCaret();
        }
    }
}
